package Biz;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import Model.Student;

/**
 * Session Bean implementation class QueryBean
 */
@Stateless
@LocalBean
public class QueryBean {

    @PersistenceContext(name = "NucleicAcidSystem")
    private EntityManager manager;
    
    public QueryBean() {
        // TODO Auto-generated constructor stub
    }
    
    public List getResult(String student_id) {
    	List results = null;
		try 
		{         
			String jpql = "select s from Student s where s.code = ?1";
			Query q = manager.createQuery(jpql);
			q.setParameter(1, student_id);
			results = q.getResultList();
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (results != null && results.size() > 0) {
			Student s = (Student)results.get(0);
			return s.getTubes();
		} else {
			return new ArrayList<Student>();
		}
    }

}
